'use strict';

angular.module('starter.controllers')

.controller('BillDetailCtrl', ['$scope', '$state','BillDetailService', function($scope, $state,BillDetailService) {
    /*$scope.bill =  {
        id:1,
        billDate: '1288323623006',
        billType: '采购收入',
        billCost: 100
    }*/
    $scope.bill =  $state.params.bill;
    $scope.events = [{
        badgeClass: 'info',
        badgeIconClass: 'fa fa-check-circle-o',
        title: '提现已经提交到财务',
        content: 'Some awesome content.'
    }, {
        badgeClass: 'warning',
        badgeIconClass: 'fa fa-circle-o',
        title: '提现成功',
        content: 'More awesome content.'
    }];

    $scope.events[0].content = $scope.bill.billDate;

    //$scope.loadData = function(){
    //   var params = {
    //            id:billId
    //        };
    //    BillDetailService.findBillById(params)
    //    .success(function(res){
    //        if(res.success){
    //            $scope.bill = res.attribute.row;
    //            $scope.billTypeName = res.attribute.billTypeName;
    //        }else{
    //            console.log('加载失败');
    //        }
    //    }).error(function(error){
    //            console.log('加载失败');
    //    });
    //};
    //$scope.loadData();
}])
.service('BillDetailService',['CrmHttp','$rootScope',function(CrmHttp,$rootScope){
    var url = '/crm/crm-bill/';
    return {
        /**
         * 全部单条结算数据
         * @param params
         * @returns {*}
         */
        findBillById: function (params) {
            var act = 'findBillById';
            return CrmHttp.post(url + act, params);
        }
    };
}]);